package test3.main;

import test3.bean.Admini;
import test3.controller.PageController;
import test3.controller.impl.PageControllerImpl;
import test3.dao.AdminiDao;
import test3.dao.impl.AdminiDaoImpl;

import java.awt.event.ActionEvent;
import java.awt.event.ActionListener;

import javax.swing.JFrame;

public class LoginAction implements ActionListener {
	Login login;
	
	public LoginAction(Login log) {
		login = log;
	}

	private PageController controller=new PageControllerImpl();
	
	@Override
	public void actionPerformed(ActionEvent e) {
		// TODO Auto-generated method stub
		String select = e.getActionCommand();
		if(select == "Login") {

			//注释掉的登陆功能

			String username = login.idText.getText();
			String password = String.valueOf(login.passwordText.getPassword());

			Admini admini=new Admini(username,password);

			if (controller.login(admini)){
				System.out.println("登陆成功");
			}else {
				System.out.println("登陆失败!");
				return;
			}

			//login.setDefaultCloseOperation(JFrame.DISPOSE_ON_CLOSE);
			login.setVisible(false);
			Index home = new Index("Information Management System",50,100,800,600);
		}
		else if(select == "Cancel") {
			System.exit(0);
		}
	}

}
